﻿namespace EyeOpen.Validation.Mapping
{
    /// <summary>
    /// A fluent interface to attach validators to a property.
    /// </summary>
    public class ValidationPropertyMap : PropertyMap
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationPropertyMap"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        public ValidationPropertyMap(string propertyName)
            : base(propertyName)
        {
        }

        /// <summary>
        /// Specifies that the value is required.
        /// </summary>
        /// <returns></returns>
        public ValidationPropertyMap Required()
        {
            AddValidator(new RequiredValidator());
            return this;
        }

        /// <summary>
        /// Specifies the maximum string length.
        /// </summary>
        /// <param name="maximumLength">The maximum length.</param>
        public void Length(int maximumLength)
        {
            AddValidator(new MinimumLengthValidator(maximumLength));
        }
    }
}